package kcms.user.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import kcms.db.User;
import kcms.user.dao.UserDAO;
import kcms.user.service.UserService;
@Service
public class UserServiceImpl implements UserService{
	@Resource
	private UserDAO userDao;
    
    public UserDAO getUserDao() {
        return userDao;
    }
    
    public void setUserDao(UserDAO userDao) {
        this.userDao = userDao;
    }
    
    public List<User> getAllUser(){
    	return userDao.getAllUser();
    }
    public User getUser(String id){
    	List<User> list =this.userDao.getUser(id);
    	if(list!=null&&list.size()>0){
    		return list.get(0);
    	}
    	else
    		return null;
    }
    @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public boolean addUser(User user) {
		return this.userDao.addUser(user);
		
	}
    @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
    public boolean updateUser(User user){
    	return this.userDao.updateUser(user);
    }
}
